import type { ProductAttrCate, ProductAttrCateItem } from '@/models/productAttrCate'
import type { PageDto, CommonResult, CommonPage } from '@/models/request'
import request from '@/utils/request'

export function fetchList(params: PageDto) {
  return request<CommonPage<ProductAttrCate>>({
    url: '/productAttribute/category/list',
    method: 'get',
    params: params,
  })
}

export function createProductAttrCate(data: { name: string }) {
  return request<CommonResult>({
    url: '/productAttribute/category/create',
    method: 'post',
    data: data,
  })
}

export function deleteProductAttrCate(id: number) {
  return request<CommonResult>({
    url: '/productAttribute/category/delete/' + id,
    method: 'get',
  })
}

export function updateProductAttrCate(id: number, data: { name: string }) {
  return request<CommonResult>({
    url: '/productAttribute/category/update/' + id,
    method: 'post',
    data: data,
  })
}
export function fetchListWithAttr() {
  return request<CommonResult<ProductAttrCateItem[]>>({
    url: '/productAttribute/category/list/withAttr',
    method: 'get',
  })
}

export function fetchProductAttributeDetail(id: number) {
  return request<CommonResult<ProductAttrCate>>({
    url: '/productAttribute/category' + id,
    method: 'get',
  })
}
